package com.nfsq.zuul.filter;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;

/**
 * @author suma
 * Created by cool8 on 2017/8/30.
 */
public class TestFilter extends ZuulFilter {

	private static final Logger logger = LoggerFactory.getLogger(TestFilter.class);

	@Override
	public String filterType() {
		return "route";
	}

	@Override
	public int filterOrder() {
		return 0;
	}

	@Override
	public boolean shouldFilter() {
		return true;
	}

	@Override
	public Object run() {
		RequestContext ctx = RequestContext.getCurrentContext();
		HttpServletRequest request = ctx.getRequest();

		String log = String.format("%s JDApiAuthFilter request to %s", request.getMethod(), request.getRequestURL().toString());
		logger.info(log);

		ctx.setSendZuulResponse(true);
		ctx.setResponseStatusCode(200);
		ctx.set("isSuccess", true);
		return null;
	}
}
